package com.wc.AlgoOJ_homework.aloj模拟赛.窗口;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/6/3 14:11
 * @description http://43.138.190.70:8888/p/LQ1373
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 100010, M = 260;
    static int[] q = new int[N];
    // window[pid]   0:x, 1:y, 2:h, 3:w 4:操作位置
    static int[][] window = new int[N][5];
    static char[][] g = new char[M][M];
    static int n, m, k;

    public static void main(String[] args) {
        n = sc.nextInt();
        m = sc.nextInt();
        k = sc.nextInt();
        int pid, x, y, h, w;
        for (int i = 1; i <= k; i++) {
            String op = sc.next();
            pid = sc.nextInt();
            if (op.equals("new")) {
                x = sc.nextInt();
                y = sc.nextInt();
                h = sc.nextInt();
                w = sc.nextInt();
                window[pid][0] = x;
                window[pid][1] = y;
                window[pid][2] = h;
                window[pid][3] = w;
            } else if (op.equals("move")) {
                x = sc.nextInt();
                y = sc.nextInt();
                window[pid][0] += x;
                window[pid][1] += y;
            } else if (op.equals("resize")) {
                h = sc.nextInt();
                w = sc.nextInt();
                window[pid][2] = h;
                window[pid][3] = w;
            }

            window[pid][4] = i;
            if (op.equals("close")) window[pid][4] = 0;
            q[i] = pid;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                g[i][j] = '.';
            }
        }
        // 画图
        for (int i = 1; i <= k; i++) {
            pid = q[i];
            // 操作到他了, 开始画图
            if (window[pid][4] == i) {
                int x1 = window[pid][0], y1 = window[pid][1];
                int x2 = x1 + window[pid][2] - 1, y2 = y1 + window[pid][3] - 1;
                // 四周的点
//                g[x1][y1] = g[x1][y2] = g[x2][y1] = g[x2][y2] = '+';
                if (check(x1, y1)) g[x1][y1] = '+';
                if (check(x1, y2)) g[x1][y2] = '+';
                if (check(x2, y1)) g[x2][y1] = '+';
                if (check(x2, y2)) g[x2][y2] = '+';

                paintRow(x1, y1, y2);
                paintRow(x2, y1, y2);
                paintCenter(x1, x2, y1, y2);
                paintCol(y1, x1, x2);
                paintCol(y2, x1, x2);
            }
        }

        // 展示
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                out.print(g[i][j]);
            }
            out.println();
        }
        out.flush();
    }

    static boolean check(int x, int y) {
        return x >= 0 && x < n && y >= 0 && y < m;
    }

    static void paintRow(int x, int y1, int y2) {
        if (x >= 0 && x < n && y1 + 1 < m && y2 - 1 >= 0) {
            int l = Math.max(0, y1 + 1), r = Math.min(m - 1, y2 - 1);
            for (int j = l; j <= r; j++) {
                g[x][j] = '-';
            }
        }
    }

    static void paintCol(int y, int x1, int x2) {
        if (y >= 0 && y < m && x1 + 1 < n && x2 - 1 >= 0) {
            int u = Math.max(0, x1 + 1), d = Math.min(n - 1, x2 - 1);
            for (int j = u; j <= d; j++) {
                g[j][y] = '|';
            }
        }
    }

    static void paintCenter(int x1, int x2, int y1, int y2) {
        int u = Math.max(0, x1 + 1), d = Math.min(x2 - 1, n - 1);
        int l = Math.max(0, y1 + 1), r = Math.min(y2 - 1, m - 1);
        for (int i = u; i <= d; i++) {
            for (int j = l; j <= r; j++) {
                g[i][j] = ' ';
            }
        }
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}